/**
 * ResourcePathInterceptor.java 1.0 2007-5-7 下午01:20:31,创建 by yangfan
 */


package org.in4j.bbs.interceptor;

import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.AroundInterceptor;
import com.opensymphony.xwork.util.CompoundRoot;
import com.opensymphony.xwork.util.OgnlValueStack;

/**
 * 页面资源文件路径
 * @author yangfan
 * @version 1.0 2007-5-7 下午01:20:31,创建
 */
public class ResourcePathInterceptor extends AroundInterceptor
{
	private static final long serialVersionUID = 1L;

	@Override
	protected void after(ActionInvocation dispatcher, String result) throws Exception
	{

	}

	@Override
	protected void before(ActionInvocation invocation) throws Exception
	{
		OgnlValueStack stack = invocation.getStack();
		String base = ServletActionContext.getRequest().getContextPath();
		String imagesPath = base + "/skin/default/images";
//		stack.setValue("images", imagesPath);
		stack.getContext().put("images", imagesPath);
		dumpStack(stack.getRoot());
		String str = stack.findString("images");
		System.out.println("str==>" + str);
	}

	private void dumpStack(CompoundRoot root)
	{
		System.out.println("---stack top---");
		for(int i = 0; i < root.size(); i++)
		{
			System.out.println(root.get(i).toString());
		}
		System.out.println("---stack bottom---");
	}

}
